package com.tzstcl.sys.monitor.model;

import com.tzstcl.commons.utils.StringUtils;
import com.tzstcl.base.model.BaseModel;

import java.io.Serializable;
import java.util.Map;

/**
 * 公司：天筑科技股份有限公司
 * 作者：zhugq
 * 日期：2018年09月21日
 * 说明：操作日志实体类
 */
public class SysOperLog extends BaseModel<SysOperLog> implements Serializable {

    // 日志类型（access：接入日志；update：修改日志；select：查询日志；loginLogout：登录登出；）
    public static final String TYPE_ACCESS = "access";
    public static final String TYPE_UPDATE = "update";
    public static final String TYPE_SELECT = "select";
    public static final String TYPE_LOGIN_LOGOUT = "loginLogout";

    private static final long serialVersionUID = 1L;
    /**
     * 日志类型
     */
    private String logType;
    /**
     * 日志标题
     */
    private String logTitle;
    /**
     * 用户名称
     */
    private String createByName;
    /**
     * 请求URI
     */
    private String requestUri;
    /**
     * 操作方式
     */
    private String requestMethod;
    /**
     * 操作提交的数据
     */
    private String requestParams;
    /**
     * 新旧数据比较结果
     */
    private String diffModifyData;
    /**
     * 业务主键
     */
    private String bizKey;
    /**
     * 业务类型
     */
    private String bizType;
    /**
     * 操作IP地址
     */
    private String remoteAddr;
    /**
     * 请求服务器地址
     */
    private String serverAddr;
    /**
     * 是否异常
     */
    private String isException;
    /**
     * 异常信息
     */
    private String exceptionInfo;
    /**
     * 用户代理
     */
    private String userAgent;
    /**
     * 设备名称/操作系统
     */
    private String deviceName;
    /**
     * 浏览器名称
     */
    private String browserName;
    /**
     * 执行时间
     */
    private Object executeTime;


    public void setLogType(String logType) {
        this.logType = logType;
    }

    public String getLogType() {
        return this.logType;
    }

    public void setLogTitle(String logTitle) {
        this.logTitle = logTitle;
    }

    public String getLogTitle() {
        return this.logTitle;
    }


    public void setCreateByName(String createByName) {
        this.createByName = createByName;
    }

    public String getCreateByName() {
        return this.createByName;
    }


    public void setRequestUri(String requestUri) {
        this.requestUri = requestUri;
    }

    public String getRequestUri() {
        return this.requestUri;
    }

    public void setRequestMethod(String requestMethod) {
        this.requestMethod = requestMethod;
    }

    public String getRequestMethod() {
        return this.requestMethod;
    }

    public void setRequestParams(String requestParams) {
        this.requestParams = requestParams;
    }

    public void setRequestParams(Map paramsMap) {
        this.requestParams = requestParams;

        if (paramsMap == null) {
            return;
        }
        StringBuilder params = new StringBuilder();
        for (Map.Entry<String, String[]> param : ((Map<String, String[]>) paramsMap).entrySet()) {
            params.append(("".equals(params.toString()) ? "" : "&") + param.getKey() + "=");
            String paramValue = (param.getValue() != null && param.getValue().length > 0 ? param.getValue()[0] : "");
            params.append(StringUtils.endsWithIgnoreCase(param.getKey(), "password") ? "*" : paramValue);
        }
        this.requestParams = params.toString();

    }

    public String getRequestParams() {
        return this.requestParams;
    }

    public void setDiffModifyData(String diffModifyData) {
        this.diffModifyData = diffModifyData;
    }

    public String getDiffModifyData() {
        return this.diffModifyData;
    }

    public void setBizKey(String bizKey) {
        this.bizKey = bizKey;
    }

    public String getBizKey() {
        return this.bizKey;
    }

    public void setBizType(String bizType) {
        this.bizType = bizType;
    }

    public String getBizType() {
        return this.bizType;
    }

    public void setRemoteAddr(String remoteAddr) {
        this.remoteAddr = remoteAddr;
    }

    public String getRemoteAddr() {
        return this.remoteAddr;
    }

    public void setServerAddr(String serverAddr) {
        this.serverAddr = serverAddr;
    }

    public String getServerAddr() {
        return this.serverAddr;
    }

    public void setIsException(String isException) {
        this.isException = isException;
    }

    public String getIsException() {
        return this.isException;
    }

    public void setExceptionInfo(String exceptionInfo) {
        this.exceptionInfo = exceptionInfo;
    }

    public String getExceptionInfo() {
        return this.exceptionInfo;
    }

    public void setUserAgent(String userAgent) {
        this.userAgent = userAgent;
    }

    public String getUserAgent() {
        return this.userAgent;
    }

    public void setDeviceName(String deviceName) {
        this.deviceName = deviceName;
    }

    public String getDeviceName() {
        return this.deviceName;
    }

    public void setBrowserName(String browserName) {
        this.browserName = browserName;
    }

    public String getBrowserName() {
        return this.browserName;
    }

    public void setExecuteTime(Object executeTime) {
        this.executeTime = executeTime;
    }

    public Object getExecuteTime() {
        return this.executeTime;
    }
}